var SQLConditionParams={
		/**
		 * 模糊查询
		 */
		 QUERY_TYPE_VAGUE:"vague",
		/**
		 * 等于查询
		 */
		QUERY_TYPE_EQUAL:"equal",
		/**
		 * 范围查询
		 */
		QUERY_TYPE_RANGE:"range",
		/**
		 * in包含查询
		 */
		QUERY_TYPE_IN:"in",
		
		/**
		 * 字符串类型
		 */
		DATA_TYPE_STRING:"string",
		/**
		 * 数字类型
		 */
		DATA_TYPE_NUMBER:"number",
		/**
		 * 时间类型
		 */
		DATA_TYPE_DATE:"date"
}



$(document).ready(function(){	
	//jQuery 1.9 移除了 $.browser 的替代方法
	jQuery.browser = {};
	jQuery.browser.mozilla = /mozilla/.test(navigator.userAgent.toLowerCase()) && !/webkit/.test(navigator.userAgent.toLowerCase());
	jQuery.browser.webkit = /webkit/.test(navigator.userAgent.toLowerCase());
	jQuery.browser.opera = /opera/.test(navigator.userAgent.toLowerCase());
	jQuery.browser.msie = /msie/.test(navigator.userAgent.toLowerCase());
	/**
	 * 使用中文环境包
	 */
	 kendo.culture("zh-CN");
	/**
	 * 使所有class为datepicker的控件转换为日期控件
	 */
	$(".datepicker").kendoDatePicker({    
	    format: "yyyy-MM-dd"
	}).keydown(function(){
        return false;
    });
	
	 
	/**
	 * 使所有input类型为数字的则转换为kendo的数字控件
	 */	
	
	$("input[type=number]").kendoNumericTextBox();
	$(".number").kendoNumericTextBox();	
    $("select").kendoComboBox();
	
	
});

/**
 * window.open防拦截
 */
function WindowOpenLocation(u){
	var w=window.open(); 
	 setTimeout(function(){ 
	 w.location=u; 
	 }, 500);
	 return false;
}

 
var Skins={
		"default":_basePath+"resource/themes/default/default.css",
		"line":_basePath+"resource/themes/line/default.css"
}
/*切换风格*/
function changeSkin(skinId)
{
	if(skinId)
	{
		$.cookie("skin",Skins[skinId]); 
		document.location.reload();
	}
}
/***
 * 更验证码
 */
function refreshCaptcha(){
	 $("#JcaptchaImages").attr('src', _basePath+'jcaptcha.do?' + Math.floor(Math.random()*100) ).fadeIn(); 
}


	
/**获取url参数*/
(function($){
	$.getUrlParam = function(name){
		var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
		var r = window.location.search.substr(1).match(reg);
		if (r!=null) return unescape(r[2]); return null;
	}
})(jQuery);



/**============检索功能平滑伸缩=======
 */
$(document).ready(function(){
	stretchSlide("divSearchTitle","divSearch","divSlide");
});
/**============检索功能平滑伸缩===Begin=======
 *@param divSearchTitle标题
 *@param divSearch搜索div
 *@param divSlide平滑
 */
function stretchSlide(divSearchTitle,divSearch,divSlide){
	$("#"+divSearchTitle).css("cursor","pointer");
	$("#"+divSearchTitle).click(function(){
   		$("#"+divSearch).slideToggle("slow");
   		if($("#"+divSlide).attr("class")=="glyphicon glyphicon-chevron-up"){
   			$("#"+divSlide).removeClass("glyphicon-chevron-up").addClass('glyphicon-chevron-down');
   		}else{
   			$("#"+divSlide).removeClass("glyphicon-chevron-down").addClass('glyphicon-chevron-up'); 
   		}
	});
}
/**============检索功能伸缩===End========*/

/**================显示消息框==Begin=========== */
function showDialog(displayDiv, w, h, title){
	var dialogDiv = $("#" + displayDiv);
		if (!dialogDiv.data("kendoWindow")) {
            dialogDiv.kendoWindow({                             
                title: title,
                width:w,
                height:h,
                modal:true,
                animation: false,
                draggable: false,
                actions: [                                  
                    "Close"
                ] 
            });                           
		}
	var dialog = dialogDiv.data("kendoWindow");
	dialog.title(title);
	dialog.center().open();
}
/**================显示消息框==End=========== */

/**
 * ===============关闭窗体======Begin=============
 * @param targetCloseWindId 关闭的提示成功之后信息窗体Id
 * @param targetGridViewId 刷新(修改/添加之后)事件Grid的Id
 * @param targetRefreshId刷新事件
 * 
 */
function closeWindow(targetCloseWindId,targetRefreshId){
	//var refreshGrid=$("#"+targetGridViewId).data("kendoGrid");
	if("call_msg_WindId"==targetCloseWindId){
		$("#call_msg_btn_Id").click(function(){
			 refreshWindow(targetCloseWindId,targetRefreshId);
		});
    }else{
    	  refreshWindow(targetCloseWindId,targetRefreshId);
    }
}
/***
 * @param targetCloseWindId 关闭的提示成功之后信息窗体Id
 * @param targetRefreshId更新或者添加成功之后再触发查询按钮刷新网格事件
 */
function refreshWindow(targetCloseWindId,targetRefreshId){
	$("#"+targetCloseWindId).data("kendoWindow").center().close();
    $("#"+targetRefreshId).click();
}

/***
*刷新表格
*/
function refreshGridView(targetRefreshId){
	  //$("#"+gridViewId).data("kendoGrid").dataSource.read();		
	  //$("#"+gridViewId).data("kendoGrid").refresh();
	   $("#"+targetRefreshId).click();
}
 
/***
 * @param targertWindow
 * @param call_msg_content_Id
 * @param html
 * @param call_msg_WindId
 * @param msg
 * @param btnSearch
 */
 function closeReturnMessageWindow(targertWindow,call_msg_content_Id,html,call_msg_WindId,msg,btnSearch){
	 $("#"+targertWindow).data("kendoWindow").close();
 	 $('#'+call_msg_content_Id).html(html);
     showDialog(call_msg_WindId, 140, 150, msg);
     closeWindow(call_msg_WindId,btnSearch);
}


/**
 *************************************************************
 *********************用户注销************************************
 *************************************************************
 */
function logout() {
	 Morinda.confirm("确认退出系统？", function(flag) {
		if (flag) {
			$.ajax( {
				type : "POST",
				url : _basePath+"logout.do",
				dataType : "json",
				success : function(responseText) {
					var status=responseText.status;
					if (status == "1") {
						document.location.href = _basePath+"jsp/admin-login.jsp";
					}else{
						document.location.href =_basePath+"jsp/main.jsp";
					}
				}
			});
		}
	});
}



/****========================================置顶Begin==================================================
 * =================================scrollUp full options===============================================
 * =====================================================================================================
 */
$(function () {
	$.scrollUp({
        scrollName: 'scrollUp', // Element ID
        scrollDistance: 300, // Distance from top/bottom before showing element (px)
        scrollFrom: 'top', // 'top' or 'bottom'
        scrollSpeed: 300, // Speed back to top (ms)
        easingType: 'linear', // Scroll to top easing (see http://easings.net/)
        animation: 'fade', // Fade, slide, none
        animationSpeed: 200, // Animation in speed (ms)
        scrollTrigger: false, // Set a custom triggering element. Can be an HTML string or jQuery object
		//scrollTarget: false, // Set a custom target element for scrolling to the top
        scrollText: '置顶', // Text for element, can contain HTML
        scrollTitle: false, // Set a custom <a> title if required.
        scrollImg: false, // Set true to use image
        activeOverlay: false, // Set CSS color to display scrollUp active point, e.g '#00FFFF'
        zIndex: 2147483647 // Z-Index for the overlay
	});
});

// Destroy example
$(function(){
	$('.destroy').click(function(){
		$.scrollUp.destroy();
	});
});
/****=======================================置顶End====================================================
 * =================================scrollUp full options==============================================
 * ====================================================================================================
 */